package bavaria.hightech.testit;


import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

import bavaria.hightech.banking.ECurrency;
import bavaria.hightech.banking.Money;

public class MoneyUnitTest {

	private Money money1;
	private Money money2;
	private Money money3;
	private Money money4;

	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		money1 = new Money(1000, ECurrency.EUR);
		money2 = new Money(500, ECurrency.EUR);
		money3 = new Money(500, ECurrency.EUR);
		money4 = new Money(500, ECurrency.GBP);
	}

	@After
	public void tearDown() throws Exception {
	}
	
	@Test
	public void testEquals(){
		assertTrue(money2.equals(money2));
		assertTrue(money2.equals(money3));
		assertTrue(money3.equals(money2));
		assertFalse(money1.equals(money2));
		assertFalse(money3.equals(money4));
	}
	
	@Test
	public void testGetValue(){
		assertEquals(1000, money1.getValue());
		assertEquals(500, money2.getValue());
		assertEquals(500, money3.getValue());

	}
	
	@Test
	public void testGetCurrency(){
		assertEquals(ECurrency.EUR, money1.getCurrency());
		assertEquals(ECurrency.GBP, money4.getCurrency());
	}
	
	@Test
	public void testEqualCurrency(){
		assertTrue(money1.equalCurrency(money2));
		assertFalse(money1.equalCurrency(money4));
	}
	
	@Test
	public void testAdd(){
		money1.add(new Money(500, ECurrency.EUR));
		assertTrue(money1.equals(new Money(1500, ECurrency.EUR)));

	}
	
	@Test
	public void testSub(){
		money1.sub(new Money(500, ECurrency.EUR));
		assertTrue(money1.equalCurrency(new Money(500, ECurrency.EUR)));
	}
	
	@Test
	public void testLowerValue(){
		assertTrue(money1.lowerValue(money2));
		assertFalse(money2.lowerValue(money1));
	}
	
	@Test
	public void testBiggerValue(){
		assertTrue(money2.biggerValue(money1));
		assertFalse(money1.biggerValue(money2));

	}
}
